<template>

  <div id="home">
    <!-- 绑定子组件$emit注册的函数，参数必须是$event -->
    <app-header :title="title" @titleChanged="updateTitle($event)"></app-header>
    <users :users="users"></users>
    <users :users="users"></users>
    <app-footer :title="title"></app-footer>
  </div>
</template>


<script>
import Users from './Users'
import Header from './Header'
import Footer from './Footer'

export default {
  name: 'home',
  data(){
    return {
        users:[],
        title:"传递的是一个值，(Number string boolean)"
    }
  },
  methods:{
    updateTitle(title){
      this.title = title;
    }
  },
  components:{
    "users":Users,
    "app-header":Header,
    "app-footer":Footer
  },
  created(){
    this.$http.get("http://jsonplaceholder.typicode.com/users").then((data) => {
      //console.log(data);
      this.users = data.body;
    });
  }
}
</script>

<style scoped>
h1{
  color:purple;
}
</style>
